<?php

/**
 * Ordinanza form.
 *
 * @package    ordinanze
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class OrdinanzaForm extends BaseOrdinanzaForm
{
  public function configure()
  {
	
	unset($this['created_at'], $this['updated_at'], $this['creato_da'], $this['modificato_da']);

	
	//URL
	$this->setWidget('url', new sfWidgetFormInputFileEditable(array('file_src' => '/uploads/allegati/'.$this->getObject()->url,'edit_mode' => !$this->isNew(), 'with_delete' => false, 'template'  => '<a href="%file%" target="_blank"><img src="/images/doc.png"/></a>',)));
	
	$this->setValidator('url', 
		new sfValidatorFile(array(
			'mime_types' => array('application/zip', 'image/jpeg', 'image/pjpeg', 'image/png', 'image/x-png', 'image/gif', 'application/x-zip', 'application/octet-stream', 'application/pdf', 'text/plain'),
			'path' => sfConfig::get('sf_upload_dir').'/allegati',
			'required' => false,)));
 
	
	//PROTOCOLLO
	$this->setWidget('protocollo', new sfWidgetFormInputText());
	$this->setValidator('protocollo', new sfValidatorString(array('max_length' => 30)));

	//STRADE LIST
	$this->widgetSchema['strade_list'] = new sfWidgetFormDoctrineChoice(array('multiple' => true, 'model' => 'Strada', 'renderer_class' => 'sfWidgetFormSelectDoubleList'));
	$this->widgetSchema['strade_list']->addOption('order_by', array('descrizione','asc'));
	
	
	//DATA EMISSIONE
	$this->widgetSchema['data_emissione'] = new sfWidgetFormDate(array('format' => '%day%/%month%/%year%'));

	
  }
}
